const Router = require('koa-router');
const router = new Router();
const tool = require('../../tools/tool')
const {db, QueryTypes} = require("../../models/db");

router.post('/menu/saveTenant', async ctx => {
    let mod = 'tenantMenu';
    let formData = ctx.request.body.formData;
    let tenantId = ctx.request.body.tenantId;
    await db.transaction(async (t) => {
        await db.models[mod].destroy({
            where: {
                tenantId: tenantId
            }
        }, )
        if(formData.length > 0) {
            await db.models[mod].bulkCreate(formData, )
        }
    })
    return ctx.suc('权限设置成功')
})


module.exports = router;
